﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="RevenueMachineAccountManagement-AccountsReceivable.aspx.cs" Inherits="NetDon.OA.Portal.Finance.RevenueMachineAccountManagement_AccountsReceivable" %>

<%@ Import Namespace="NetDon.OA.Interface" %>
<%@ Import Namespace="NetDon.OA.Portal" %>
<%@ Import Namespace="NetDon.Utilities" %>
<%@ Register Src="../Controls/GridPager.ascx" TagName="GridPager" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script language="javascript" type="text/javascript">
        var userDialogSize = { width: 1000, height: window.top.$common.getClientBounds().height - 200 };




        function viewOrder(sender, args) {
            var orderId = $attr(sender.get_selectedRow(), 'Id');
            $dialog('<%= ResolveUrl("~/Finance/ConfirmAccountReceipt.aspx")%>?ViewModel=true&Id=' + orderId, userDialogSize, function (result) {
                if (result) {
                    $get('<%=btnReload.ClientID %>').click();
                }
            });
        }


        function modifyOrder(orderId) {
            $dialog('<%=ResolveUrl("~/Finance/ConfirmAccountReceipt.aspx") %>?ViewModel=true&Id=' + orderId, userDialogSize, function (result) {
                if (result) {
                    $get('<%=btnReload.ClientID %>').click();
                }
            });
        }



        function deleteOrderReceipt(orderId) {
            $confirm("确定要删除该笔收款吗？", function (result) {
                if (result) {
                    $text($get('<%=fieldOrderId.ClientID %>'), orderId);
                    $get('<%=btnHiddenDelete.ClientID %>').click();
                }
            });
        }

        function confirmOrderInvoice(orderId) {
            $confirm("确认付款完成吗？", function (result) {
                if (result) {
                    $text($get('<%=fieldOrderId.ClientID %>'), orderId);
                    $get('<%=btnConfirmOrderInvoice.ClientID %>').click();
                }
            });
        }
        

  
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:UpdatePanel ID="UpdatePanelFlow" runat="server">
        <ContentTemplate>
            <asp:Panel ID="Panel1" runat="server" DefaultButton="btnSearch">
                <table border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td>
                            <NetDon:FormPanel ID="PanelCondition" runat="server" CaptionAlign="NotSet" RepeatColumns="2">
                                <Items>
                                    <NetDon:FormItem HeaderText="客户">
                                        <ContentTemplate>
                                            <asp:DropDownList ID="ddlCustomer" runat="server" DataSourceID="ObjectDataSourceCustomers"
                                                DataTextField="CustomerName" DataValueField="CustomerId" AppendDataBoundItems="true">
                                            </asp:DropDownList>
                                            <asp:ObjectDataSource ID="ObjectDataSourceCustomers" runat="server" OldValuesParameterFormatString="original_{0}"
                                                SelectMethod="RetrieveCustomers" TypeName="NetDon.OA.Business.MiscDataSource">
                                                <SelectParameters>
                                                    <asp:Parameter Name="areaId" />
                                                </SelectParameters>
                                            </asp:ObjectDataSource>
                                        </ContentTemplate>
                                    </NetDon:FormItem>
                                    <NetDon:FormItem HeaderText="线路分类">
                                        <ContentTemplate>
                                            <asp:DropDownList ID="ddlRouteTypeId" DataSourceID="ddsRouteTypeId" AppendDataBoundItems="True"
                                                runat="server" DataTextField="Name" DataValueField="Value">
                                            </asp:DropDownList>
                                            <NetDon:DictionaryDataSource ID="ddsRouteTypeId" runat="server" CategoryName="线路分类"
                                                EmptyItemType="Select">
                                            </NetDon:DictionaryDataSource>
                                        </ContentTemplate>
                                    </NetDon:FormItem>
                                    <NetDon:FormItem HeaderText="开票否">
                                        <ContentTemplate>
                                            <asp:RadioButton ID="radioIsInvoiceNeededYes" runat="server" Text="是" GroupName="IsInvoiceNeeded"
                                                Checked="True" Enabled="False"></asp:RadioButton>
                                        </ContentTemplate>
                                    </NetDon:FormItem>
                                    <NetDon:FormItem HeaderText="开票日期">
                                        <ContentTemplate>
                                            <asp:TextBox ID="txtConfirmInvoiceDateStart" runat="server" Width="75px"></asp:TextBox>
                                            <asp:CalendarExtender ID="CalendarExtender5" runat="server" Enabled="True" TargetControlID="txtConfirmInvoiceDateStart"
                                                Format="yyyy-MM-dd">
                                            </asp:CalendarExtender>
                                            <asp:Label ID="Label3" runat="server" Text="~" Style="margin-left: 5px; margin-right: 6px"></asp:Label>
                                            <asp:TextBox ID="txtConfirmInvoiceDateEnd" runat="server" Width="75px"></asp:TextBox>
                                            <asp:CalendarExtender ID="CalendarExtender6" runat="server" Enabled="True" TargetControlID="txtConfirmInvoiceDateEnd"
                                                Format="yyyy-MM-dd">
                                            </asp:CalendarExtender>
                                        </ContentTemplate>
                                    </NetDon:FormItem>
                                    <NetDon:FormItem HeaderText="发票号码">
                                        <ContentTemplate>
                                            <asp:TextBox ID="txtInvoiceNo" runat="server"></asp:TextBox>
                                        </ContentTemplate>
                                    </NetDon:FormItem>
                                    <NetDon:FormItem HeaderText="收款日期">
                                        <ContentTemplate>
                                            <asp:TextBox ID="txtConfirmAccountsReceiptDateStart" runat="server" Width="75px"
                                                ></asp:TextBox>
                                            <asp:CalendarExtender ID="CalendarExtender7" runat="server" Enabled="True" TargetControlID="txtConfirmAccountsReceiptDateStart"
                                                Format="yyyy-MM-dd">
                                            </asp:CalendarExtender>
                                            <asp:Label ID="Label4" runat="server" Text="~" Style="margin-left: 5px; margin-right: 6px"></asp:Label>
                                            <asp:TextBox ID="txtConfirmAccountsReceiptDateEnd" runat="server" Width="75px" ></asp:TextBox>
                                            <asp:CalendarExtender ID="CalendarExtender8" runat="server" Enabled="True" TargetControlID="txtConfirmAccountsReceiptDateEnd"
                                                Format="yyyy-MM-dd">
                                            </asp:CalendarExtender>
                                        </ContentTemplate>
                                    </NetDon:FormItem>
                                    <NetDon:FormItem HeaderText="承运公司">
                                        <ContentTemplate>
                                            <asp:DropDownList ID="ddlCompany" runat="server" DataSourceID="ObjectDataSourceCompany"
                                                DataTextField="CompanyName" DataValueField="CompanyId" AppendDataBoundItems="true">
                                            </asp:DropDownList>
                                            <asp:ObjectDataSource ID="ObjectDataSourceCompany" runat="server" OldValuesParameterFormatString="original_{0}"
                                                SelectMethod="RetrieveCompanies" TypeName="NetDon.OA.Business.MiscDataSource">
                                            </asp:ObjectDataSource>
                                        </ContentTemplate>
                                    </NetDon:FormItem>
                                </Items>
                            </NetDon:FormPanel>
                        </td>
                        <td valign="bottom">
                            <asp:Button ID="btnSearch" SkinID="Button60" runat="server" OnClick="btnSearch_Click"
                                Text="查询"></asp:Button>
                            <asp:Button ID="btnReload" runat="server" SkinID="Hidden" OnClick="btnReload_Click" />
                        </td>
                    </tr>
                </table>
            </asp:Panel>
            <div style="margin-top: 10px">
                <NetDon:GridView ID="gridOrderList" runat="server" AutoGenerateColumns="False" AllowSorting="true" OnRowDetailCreated="gridProductList_RowDetailCreated" DataKeyNames="Id"
                    OnClientRowDblClick="viewOrder" OnRowDataBound="gridOrderList_RowDataBound">
                    <Columns>
                        <NetDon:BoundField HeaderText="客户" DataField="CustomerName" SortExpression="CustomerName">
                        </NetDon:BoundField>
                        <NetDon:TemplateField HeaderText="线路分类" SortExpression="RouteTypeId">
                            <ItemTemplate>
                                <%#GetDictionaryItemName(Eval("RouteTypeId"))%>
                            </ItemTemplate>
                        </NetDon:TemplateField>
                        <NetDon:BoundField HeaderText="开票日期" DataField="ConfirmInvoiceDate" DataFormatString="{0:yyyy-MM-dd}"
                            SortExpression="ConfirmInvoiceDate">
                        </NetDon:BoundField>
                        <NetDon:BoundField HeaderText="发票号码" DataField="InvoiceNO" SortExpression="InvoiceNO">
                        </NetDon:BoundField>
                        <NetDon:TemplateField HeaderText="开票金额(￥)" SortExpression="InvoiceAmount">
                            <ItemTemplate>
                                <%#!MiscUtilities.IsNullOrEmpty(Eval("InvoiceAmount")) ? ((Decimal)Eval("InvoiceAmount")).ToString("#,###.00") : ""%>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Right"></ItemStyle>
                        </NetDon:TemplateField>
                        <NetDon:TemplateField HeaderText="实收金额(￥)" SortExpression="TotalAccountReceiptAmount">
                            <ItemTemplate>
                                <%#!MiscUtilities.IsNullOrEmpty(Eval("TotalAccountReceiptAmount")) ? ((Decimal)Eval("TotalAccountReceiptAmount")).ToString("#,###.00") : ""%>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Right"></ItemStyle>
                        </NetDon:TemplateField>
                        <NetDon:TemplateField HeaderText="未付金额(￥)" SortExpression="UnReceivedAmount">
                            <ItemTemplate>
                                <%#!MiscUtilities.IsNullOrEmpty(Eval("UnReceivedAmount")) ? ((Decimal)Eval("UnReceivedAmount")).ToString("#,###.00") : ""%>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Right"></ItemStyle>
                        </NetDon:TemplateField>
                        <NetDon:BoundField HeaderText="异常情况" DataField="AccountReceiptExceptions" SortExpression="AccountReceiptExceptions">
                        </NetDon:BoundField>
                        <NetDon:BoundField HeaderText="开票备注" DataField="InvoiceDescription" SortExpression="InvoiceDescription">
                        </NetDon:BoundField>
                        <NetDon:BoundField HeaderText="收款备注" DataField="AccountReceiptComments" SortExpression="AccountReceiptComments">
                        </NetDon:BoundField>
                        <NetDon:BoundField HeaderText="更新时间" DataField="LastUpdatedDate" SortExpression="LastUpdatedDate"
                            DataFormatString="{0:yyyy-MM-dd}">
                        </NetDon:BoundField>
                        <NetDon:BoundField HeaderText="更新人" SortExpression="LastUpdatedBy" DataField="UserName">
                        </NetDon:BoundField>
                        <NetDon:TemplateField HeaderText="操作" ItemStyle-Width="50px">
                            <ItemTemplate>
                                <asp:ImageButton ID="btnEdit" runat="server" SkinID="Modify" ImageAlign="AbsMiddle"
                                    CausesValidation="false" />
                                <asp:ImageButton ID="btnConfirm" runat="server" SkinID="Confirm" />
                            </ItemTemplate>
                        </NetDon:TemplateField>
                    </Columns>
                    <DetailSettings HeaderText="收款明细" ColumnWidth="100px" CollapseText="隐藏" ExpandText="查看"
                        ExpandImageUrl="~/Images/Button/expand.jpg" CollapseImageUrl="~/Images/Button/collapse.jpg"
                        TargetControlID="pnlInvoiceReceipt">
                    </DetailSettings>
                </NetDon:GridView>
                <uc1:GridPager ID="PageQueryAdapter1" runat="server" TargetControlID="gridOrderList"
                    OnPerformGetCondition="PageQueryAdapter1_PerformGetCondition" OnPerformGetRecordCount="PageQueryAdapter1_PerformGetRecordCount"
                    OnPerformGetPageData="PageQueryAdapter1_PerformGetPageData" />
            </div>
            <asp:Panel ID="pnlInvoiceReceipt" runat="server" Visible="false" ScrollBars="None"
                BorderColor="White">
                <div style="width: 900px; overflow-x: auto;">
                    <asp:GridView ID="grdInvoiceReceipt" BorderWidth="0px" CellPadding="0" CellSpacing="0"
                        Width="100%" AutoGenerateColumns="false" runat="server" OnRowDataBound="grdInvoiceReceipt_RowDataBound">
                        <Columns>
                            <asp:BoundField HeaderText="银票号码" DataField="BankNoteNO" SortExpression="BankNoteNO">
                            </asp:BoundField>
                            <asp:TemplateField HeaderText="币种" SortExpression="CurrencyType">
                                <ItemTemplate>
                                    <%#GetDictionaryItemName(Eval("CurrencyType"))%>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="实收金额(￥)" SortExpression="AccountsReceiptAmount">
                                <ItemTemplate>
                                    <%#!MiscUtilities.IsNullOrEmpty(Eval("AccountsReceiptAmount")) ? ((Decimal)Eval("AccountsReceiptAmount")).ToString("#,###.00") : ""%>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Right"></ItemStyle>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="收款方式" SortExpression="AccountsReceiptType">
                                <ItemTemplate>
                                    <%#GetDictionaryItemName(Eval("AccountsReceiptType"))%>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField HeaderText="收款日期" DataField="ConfirmAccountsReceiptDate" SortExpression="ConfirmAccountsReceiptDate"
                                DataFormatString="{0:yyyy-MM-dd}"></asp:BoundField>
                            <asp:BoundField HeaderText="汇票到期日" DataField="BillOfExchangeDueDate" SortExpression="BillOfExchangeDueDate"
                                DataFormatString="{0:yyyy-MM-dd}"></asp:BoundField>
                            <asp:TemplateField HeaderText="备注">
                                <ItemTemplate>
                                    <%#Server.HtmlEncode(!MiscUtilities.IsNullOrEmpty(Eval("Comments")) ? Eval("Comments").ToString() : "")%>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="操作" ItemStyle-Width="100px">
                                <ItemTemplate>
                                    <asp:ImageButton ID="btnDelete" runat="server" SkinID="Delete" />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <HeaderStyle CssClass="test" />
                        <RowStyle CssClass="test" />
                        <AlternatingRowStyle CssClass="GridRow1" />
                    </asp:GridView>
                </div>
            </asp:Panel>
            <asp:HiddenField ID="fieldOrderId" runat="server" />
            <asp:Button ID="btnHiddenDelete" runat="server" OnClick="btnDelete_Click" Text="Delete"
                SkinID="Hidden" />
            <asp:Button ID="btnConfirmOrderInvoice" runat="server" OnClick="btnConfirmOrderInvoice_Click"
                SkinID="Hidden" />
        </ContentTemplate>
    </asp:UpdatePanel>
    <script type="text/javascript">

        function pageLoad() {
            setTimeout(function () {
                function showDetail(index) {
                    var grid = $find('<%=gridOrderList.ClientID%>');
                    if (grid._rows.length <= index) return;
                    var row = grid._rows[index];
                    var elements = row.getElementsByTagName("input"); //the last input is the details loading 
                    grid.showDetail(index, elements[elements.length - 1], function () {
                        showDetail(index + 1);
                    });
                }

                showDetail(0);

            }, 0);
        }

    </script>
</asp:Content>
